In order to summarize the SE network information we will perform the module eigengene approach. Module eigengene is defined as the first principal component of the expression matrix of the corresponding module.
macro_type = params$cell_type #macro_structure. It can be cell_type, metabolites, region of the brain.
message(paste0("Cell type: ", macro_type))## Cell type: inh
# Expression data for a single set in the form of a data frame where rows are samples and columns are genes (probes):
exprData = read.table(paste0(expression_dir, macro_type, ".txt"), header = T, stringsAsFactors = F, check.names = F) # Results of the expression
expr_matx_t = as.data.frame( t(exprData)) # Residuals of the expression
# Gene by module
gene_mod = read.table(paste0(net_dir, macro_type, "/geneBycluster.txt"), header = T, stringsAsFactors = F) # clusters from SpeakEasy
k_dataset_ord = gene_mod[match(colnames(expr_matx_t), gene_mod$ensembl), ] #order the matrices
all(colnames(expr_matx_t) == k_dataset_ord$ensembl) # must be true ## [1] TRUE
Showing the module eigengenes in a dataframe, with each column corresponding to one eigengene.
colors = k_dataset_ord$cluster_lv3
lv3_moduleEigengenes = moduleEigengenes(expr_matx_t, colors, verbose = 0)
# save results
save(lv3_moduleEigengenes, file = paste0(net_dir, macro_type,"/", "lv3_moduleEigengenes.Rdata"))
write.table(lv3_moduleEigengenes$eigengenes, file = paste0(net_dir, macro_type,"/", "lv3_moduleEigengenes.txt"), sep = "\t", quote = F, row.names = T)
createDT(lv3_moduleEigengenes$eigengenes)A dataframe containing average normalized expression in each module.
# The columns are named by the corresponding color with an "AE" prepended, e.g., AEturquoise etc.
colnames(lv3_moduleEigengenes$averageExpr) = gsub("AE", "AE_M", colnames(lv3_moduleEigengenes$averageExpr))
write.table(lv3_moduleEigengenes$averageExpr, file = paste0(net_dir, macro_type,"/", "lv3_averageExpr.txt"), sep = "\t", quote = F, row.names = T)
createDT(lv3_moduleEigengenes$averageExpr)sessionInfo()## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: CentOS Stream 8
##
## Matrix products: default
## BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.15.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] grid stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] WGCNA_1.70-3 fastcluster_1.2.3 dynamicTreeCut_1.63-1 janitor_2.1.0 broom_0.7.12 ComplexHeatmap_2.11.1 DT_0.20
## [8] plotly_4.10.0 knitr_1.37 gprofiler2_0.2.1 ggeasy_0.1.3 readxl_1.3.1 kableExtra_1.3.4 R.matlab_3.6.2
## [15] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.8 purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.6
## [22] tidyverse_1.3.1 limma_3.50.1 ggfortify_0.4.14 ggplot2_3.3.5
##
## loaded via a namespace (and not attached):
## [1] backports_1.4.1 circlize_0.4.14 Hmisc_4.6-0 systemfonts_1.0.4 plyr_1.8.6 lazyeval_0.2.2 splines_4.1.2
## [8] crosstalk_1.2.0 listenv_0.8.0 GenomeInfoDb_1.30.1 digest_0.6.29 foreach_1.5.2 htmltools_0.5.2 GO.db_3.14.0
## [15] fansi_1.0.2 checkmate_2.0.0 magrittr_2.0.2 memoise_2.0.1 cluster_2.1.2 doParallel_1.0.17 tzdb_0.2.0
## [22] globals_0.14.0 Biostrings_2.62.0 modelr_0.1.8 matrixStats_0.61.0 R.utils_2.11.0 svglite_2.1.0 jpeg_0.1-9
## [29] colorspace_2.0-3 blob_1.2.2 rvest_1.0.2 haven_2.4.3 xfun_0.29 crayon_1.5.0 RCurl_1.98-1.6
## [36] jsonlite_1.7.3 impute_1.68.0 survival_3.2-13 iterators_1.0.14 glue_1.6.1 gtable_0.3.0 zlibbioc_1.40.0
## [43] XVector_0.34.0 webshot_0.5.2 GetoptLong_1.0.5 shape_1.4.6 BiocGenerics_0.40.0 scales_1.1.1 DBI_1.1.2
## [50] Rcpp_1.0.8 htmlTable_2.4.0 viridisLite_0.4.0 clue_0.3-60 foreign_0.8-81 bit_4.0.4 preprocessCore_1.56.0
## [57] Formula_1.2-4 stats4_4.1.2 htmlwidgets_1.5.4 httr_1.4.2 RColorBrewer_1.1-2 ellipsis_0.3.2 pkgconfig_2.0.3
## [64] R.methodsS3_1.8.1 sass_0.4.0 nnet_7.3-16 dbplyr_2.1.1 utf8_1.2.2 tidyselect_1.1.2 rlang_1.0.1
## [71] reshape2_1.4.4 AnnotationDbi_1.56.2 munsell_0.5.0 cellranger_1.1.0 tools_4.1.2 cachem_1.0.6 cli_3.2.0
## [78] generics_0.1.2 RSQLite_2.2.10 evaluate_0.15 fastmap_1.1.0 yaml_2.3.5 bit64_4.0.5 fs_1.5.2
## [85] KEGGREST_1.34.0 future_1.24.0 R.oo_1.24.0 xml2_1.3.3 compiler_4.1.2 rstudioapi_0.13 png_0.1-7
## [92] reprex_2.0.1 bslib_0.3.1 stringi_1.7.6 lattice_0.20-45 Matrix_1.3-4 ggsci_2.9 vctrs_0.3.8
## [99] pillar_1.7.0 lifecycle_1.0.1 jquerylib_0.1.4 GlobalOptions_0.1.2 data.table_1.14.2 bitops_1.0-7 R6_2.5.1
## [106] latticeExtra_0.6-29 gridExtra_2.3 IRanges_2.28.0 parallelly_1.30.0 codetools_0.2-18 assertthat_0.2.1 rjson_0.2.21
## [113] withr_2.4.3 S4Vectors_0.32.3 GenomeInfoDbData_1.2.7 parallel_4.1.2 hms_1.1.1 rpart_4.1-15 rmarkdown_2.11
## [120] snakecase_0.11.0 Biobase_2.54.0 lubridate_1.8.0 base64enc_0.1-3